package chapter5.shutdown_hook;

import org.springframework.context.support.GenericXmlApplicationContext;

import chapter5.implement_disposablebean.DestructiveBeanWithInterface;

/**
 * 
 * @author chauthang
 * @comment example using ctx.registerShutdownHook(); will auto destroy bean
 */
public class ShutdownHookExample {
	public static void main(String[] args) {
		GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
		ctx.load("classpath:chapter5/implement_disposablebean/disposeInterface.xml");
		ctx.registerShutdownHook();
		ctx.refresh();

		DestructiveBeanWithInterface bean = (DestructiveBeanWithInterface) ctx
				.getBean("destructiveBeanWithInterface");
	}
}
